package com.yalantis.ucrop.util;

import android.content.Context;
import android.os.Build;
import android.view.View;

/**
 * Created by qianlu on 2018/4/11.
 * 邮箱：zar.l@qq.com
 */
public class ViewUtils {

    public static void paddingToStatusBar(View view) {
        if (!(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)) return;
        view.setPadding(view.getPaddingLeft(), view.getPaddingTop() + ViewUtils.getStatusBarHeight(view.getContext()), view.getPaddingRight(), view.getPaddingBottom());
        // view.setPadding(0, ViewUtils.getStatusBarHeight(view.getContext()), 0, 0);
    }

    public static int getStatusBarHeight(Context context) {
        int result = 0;
        int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
        if (resourceId > 0) {
            result = context.getResources().getDimensionPixelOffset(resourceId);
        }
        return result;
    }
}
